import yaml
import os

with open('config.yml', 'r') as f:
    config = yaml.safe_load(f)


def get_uploaded_video_path(file_name: str) -> str:
    input_dir = config['input_video_dir']
    if not os.path.exists(input_dir):
        raise Exception('input video directory not exists')
    video_path = input_dir + file_name
    return video_path

def output_in_video_dir(file_name):
    # 定义输出视频文件 输出文件名为 原名+in.后缀
    file_name_map = os.path.splitext(file_name)
    output_dir = config['output_video_dir']
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)
    output_video = output_dir + file_name_map[0] + "in" + file_name_map[1]
    return output_video


def output_video_dir(file_name):
    # 定义输出视频文件 输出文件名为 原名+out.后缀
    file_name_map = os.path.splitext(file_name)
    output_dir = config['output_video_dir']
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)
    output_video = output_dir + file_name_map[0] + "out" + file_name_map[1]
    return output_video
